package com.woniuxy.hibernate.run;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.woniuxy.hibernate.entity.User;

public class LoginRun {
	
	private Session session;
	private SessionFactory sessionFactory;
	
	
	

	
	public String get(String userName) {
		Configuration configuration = new Configuration().configure();
		sessionFactory = configuration.buildSessionFactory();
		session = sessionFactory.openSession();

		Transaction transaction = session.beginTransaction();

		User user = new User();
		user.setUserName(userName);

		session.get(User.class, userName);

		transaction.commit();
		System.out.println(user.getPassWord());
		
		
		session.close();
		sessionFactory.close();
		return user.getPassWord();
	}
}
